package com.igeek.boot.controller;

import com.igeek.boot.result.Result;
import com.igeek.boot.service.GeoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.geo.GeoResults;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author fengqq
 * @Description TODO
 * @Date 2024/9/5  10:27
 */
@RestController
@RequestMapping("/geo")
@Api(tags = "地理位置的控制层")
@Slf4j
public class GeoController {
    @Autowired
    private GeoService geoService;

    //添加景点
    @GetMapping("/add")
    @ApiOperation("添加景点")
    public Result add(){
        boolean flag = geoService.add();
        return new Result(200,"添加成功");
    }

    //以当前位置获取附近的景点
    @GetMapping("/findByPoint")
    @ApiOperation("以当前位置获取附近的景点")
    public Result findByPoint( String longitude,String latitude ){
        GeoResults result = geoService.findByPoint(longitude,latitude);
        return new Result(200,"查询成功",result);
    }

    //根据指定的景点名称 来获取它附近的景点
    @GetMapping("/findByMember")
    @ApiOperation("根据指定的景点名称获取附近的景点")
    public Result findByMember( String member ){
        GeoResults result = geoService.findByMember(member);
        return new Result(200,"查询成功",result);
    }
}
